/*
 * Copyright (C) 2013 Michael
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package com.jm.jmsql.sql.predictions;

import com.jm.jmsql.objects.base.JMSqlObject;
import com.jm.jmsql.utils.Constants;
import java.awt.Color;

/**
 *
 * @author Michael L.R. Marques
 */
public class SQLPrediction extends javax.swing.JPanel {
    
    //
    private JMSqlObject object;

    /**
     * Creates new form SQLPrediction
     */
    private SQLPrediction(JMSqlObject object) {
        this.object = object;
        initComponents();
        //
        this.lblObject.setIcon(object.getIcon());
        this.lblObject.setText(object.getName());
        this.lblDescription.setText(object.getObjectType().toString());
    }
    
    /**
     * 
     * @return 
     */
    public JMSqlObject getJMSqlObject() {
        return this.object;
    }
    
    /**
     * 
     * @param object
     * @param selected
     * @return 
     */
    public static SQLPrediction generate(JMSqlObject object, boolean selected) {
        SQLPrediction prediction = new SQLPrediction(object);
        prediction.setBackground(selected ? Constants.Colours.LIGHT_BLUE : Color.white);
        prediction.lblDescription.setForeground(selected ? Color.white : Color.lightGray);
        return prediction;
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblObject = new javax.swing.JLabel();
        lblDescription = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        lblObject.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        lblObject.setText("Object");
        lblObject.setAlignmentX(1.5F);

        lblDescription.setForeground(new java.awt.Color(153, 153, 153));
        lblDescription.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblDescription.setText("Description");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(lblObject, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblDescription, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblDescription, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)
            .addComponent(lblObject, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lblDescription;
    private javax.swing.JLabel lblObject;
    // End of variables declaration//GEN-END:variables
}
